import React, { Component } from 'react'
class App extends Component {
  render() {
    return (
      <div>
        <button onClick={this.props.add}></button>
        <span>{this.props.num}</span>
        <button onClick={this.props.sub}></button>
      </div>
    )
  }
}

function fn(WrappedComponent) {
  return class extends Component{
    state = {
      num:555
    }
    add=(params) => {
      this.setState({
        num:this.state.num+1
      })
    }
    sub=(params) => {
      this.setState({
        num:this.state.num-1
      })
    }
    render() {
      return <WrappedComponent num={this.state.num} add={this.add} sub={this.sub}></WrappedComponent>
    }
  }
}

export default fn(App)